;;;
;;;
;;;	Author:	Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;		http://paracadd.com
;;;		All rights reserved.
;;;
;;;		COPYRIGHT: 7/26/2010
;;;		   EDITED: 7/26/2010
;;;
(DEFUN C:SBRKL ()
  (IF dimscl NIL (LOAD "dimscl" "\nFile DIMSCL.LSP not loaded! "))
  (IF upoint NIL (LOAD "upoint" "\nFile UPOINT.LSP not loaded! "))
  (IF gvpno NIL (LOAD "gvpno" "\nFile GVPNO.LSP not loaded! "))
  (IF c:mklayr NIL (LOAD "mklayr" "\nFile MKLAYR.LSP not loaded! "))
  (c:svlayr)
  (gvpno)
  (dimscl)
  (WHILE
    (AND
      dimscl
      upoint
      (SETQ brkl_ptb (upoint 0 "" "Begin breakline point" nil nil))
      (SETQ brkl_pte (upoint 0 "" "End breakline point" nil brkl_ptb))
    )
    (SETQ brkl_len (DISTANCE (LIST (CAR brkl_ptb)(CADR brkl_ptb) 0.0) (LIST (CAR brkl_pte)(CADR brkl_pte) 0.0))
          brkl_ang (ANGLE (LIST (CAR brkl_ptb)(CADR brkl_ptb) 0.0) (LIST (CAR brkl_pte)(CADR brkl_pte) 0.0))
          brkl_seg (/ dimsc 12.0)
          brkl_fzl (/ brkl_seg 6.0)
          brkl_fza (/ pi 90.0)
          brkl_pt_lst (LIST brkl_ptb)
          this_path (GETVAR "DWGPREFIX")
    )
    (IF mjrg (SETQ this_mjrg mjrg)
    	    (cond
	      ((wcmatch (strcase this_path) "*01 GENERAL*")
	       (setq this_mjrg "G")
	      )
	      ((wcmatch (strcase this_path) "*02 CIVIL*")
	       (setq this_mjrg "C")
	      )
	      ((wcmatch (strcase this_path) "*03 STRUCTURAL*")
	       (setq this_mjrg "S")
	      )
	      ((wcmatch (strcase this_path) "*04 ARCHITECTURAL*")
	       (setq this_mjrg "A")
	      )
	      ((wcmatch (strcase this_path) "*05 P&ID*")
	       (setq this_mjrg "I")
	      )
	      ((wcmatch (strcase this_path) "*06 ENVIRONMENTAL*")
	       (setq this_mjrg "M")
	      )
	      ((wcmatch (strcase this_path) "*06 MECHANCIAL*")
	       (setq this_mjrg "M")
	      )
	      ((wcmatch (strcase this_path) "*07 TELEMETRY*")
	       (setq this_mjrg "T")
	      )
	      ((wcmatch (strcase this_path) "*08 ELECTRICAL*")
	       (setq this_mjrg "E")
	      )
	      ((wcmatch (strcase this_path) "*09 MECHANICAL*")
	       (setq this_mjrg "M")
	      )
	      ((wcmatch (strcase this_path) "*09 HVAC*")
	       (setq this_mjrg "H")
	      )
	      ((wcmatch (strcase this_path) "*10 PLUMBING*")
	       (setq this_mjrg "P")
	      )
	      ((wcmatch (strcase this_path) "*11 FIRE*")
	       (setq this_mjrg "F")
	      )
	      ((wcmatch (strcase this_path) "*12 LANDSCAPE*")
	       (setq this_mjrg "L")
	      )
              (T (SETQ this_mjrg (ukword 1 "A C E F G H I L M P S" "CAD Layer Guidelines (CLG) Major Group [A/C/E/F/G/H/I/L/M/P/S]" (IF mjrg mjrg "C"))))
	    ) ;_ end of COND
      )
    (SETQ thisprod "DETL"
          thiscolor "4"
          thismodf "BRKL"
          thisname (STRCASE (STRCAT this_mjrg "-" thisprod thiscolor thismodf))
          thisltname "continuous"
          start_ang (ANGLE brkl_ptb brkl_pte)
    )
    (WHILE (AND (> brkl_seg 0.0)(EQ (ANGLE brkl_ptb brkl_pte) start_ang)(> (DISTANCE brkl_ptb brkl_pte) (* 1.5 brkl_seg)))
      (SETQ brkl_ptb (POLAR brkl_ptb (ANGLE brkl_ptb brkl_pte) brkl_seg))
      (SETQ brkl_pt_lst (APPEND brkl_pt_lst (LIST brkl_ptb)))
    )
    (SETQ ang_sign 1)
    (FOREACH n brkl_pt_lst
      (SETQ this_pt (POLAR n (+(* PI(IF(EQ ang_sign 1)0.5 1.5))(*(IF(EQ ang_sign 1)1.0 -1.0)(/(REM(DOS_RANDOM)90)180.0))brkl_ang)(*(MAX 1(REM(DOS_RANDOM)3))brkl_fzl)))
      (IF (EQUAL n (CAR brkl_pt_lst))
        NIL
        (SETQ brkl_pt_lst (SUBST this_pt n brkl_pt_lst))
      )
      (SETQ ang_sign (ABS (1- ang_sign)))
    )
    (SETQ brkl_pt_lst (APPEND brkl_pt_lst (LIST brkl_pte)))
    (layentmake thisname thiscolor thisltname)
    (ENTMAKE
        (LIST (CONS 0 "POLYLINE")
              (CONS 6 "BYLAYER")
              (CONS 40 0)
              (CONS 41 0)
              (CONS 62 256)
              (CONS 66 1)
              (CONS 70 128)
              (CONS 8 thisname)
              (CONS 10 (LIST (CAAR brkl_pt_lst)(CADAR brkl_pt_lst)))
        ) ;_ end of LIST
    ) ;_ end of ENTMAKE
    (FOREACH n brkl_pt_lst
      (ENTMAKE
          (LIST (CONS 0 "VERTEX")
                (CONS 6 "BYLAYER")
                (CONS 40 0)
                (CONS 41 0)
                (CONS 62 256)
                (CONS 8 thisname)
                (CONS 10 (LIST (CAR n)(CADR n)))
          ) ;_ end of LIST
      ) ;_ end of ENTMAKE
    ) ;_ end of WHILE
    (ENTMAKE (LIST (CONS 0 "SEQEND")))
  )
  (c:rslayr)
  (COND
    ((AND (NOT dimscl) (NOT upoint) (NOT gvpno))
     (ALERT "Required subroutines DIMSCL.LSP, GVPNO.LSP, and UPOINT.LSP were not loaded!\nThese are available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((AND (NOT dimscl) (NOT upoint))
     (ALERT "Required subroutines DIMSCL.LSP and UPOINT.LSP were not loaded!\nThese are available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((AND (NOT dimscl) (NOT gvpno))
     (ALERT "Required subroutines DIMSCL.LSP and GVPNO.LSP were not loaded!\nThese are available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((AND (NOT upoint) (NOT gvpno))
     (ALERT "Required subroutines GVPNO.LSP and UPOINT.LSP were not loaded!\nThese are available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((NOT dimscl)
     (ALERT "Required subroutine DIMSCL.LSP was not loaded!\nDIMSCL.LSP is available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((NOT gvpno)
     (ALERT "Required subroutine GVPNO.LSP was not loaded!\nGVPNO.LSP is available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
    ((NOT upoint)
     (ALERT "Required subroutine UPOINT.LSP was not loaded!\nUPOINT.LSP is available free from: \"http://www.paracadd.com/lisp/lisp_lst.htm\""))
  )
  (PRINC)
)